package com.example.parking;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;


public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
    //enter parking menu
    Button button1 = (Button)findViewById(R.id.button1);
    button1.setOnClickListener(new OnClickListener() {
    	public void onClick(View v){
    		Intent intent = new Intent(MainActivity.this, NewActivity.class);
    		startActivity(intent);
    	}
    });
    
    //action out
    Button button2 = (Button)findViewById(R.id.button2);
    button2.setOnClickListener(new OnClickListener(){
    	public void onClick(View v) {
    		AlertDialog dialog = createDialogBox();
    		dialog.show();
    	}
    });
    }
    
    //menu box - yes or no
    private AlertDialog createDialogBox(){
    	AlertDialog.Builder builder = new AlertDialog.Builder(this);
    	
    	builder.setTitle("INFO");
    	builder.setMessage("DO YOU WANT TO GO OUT?");
    	builder.setIcon(R.drawable.abc_ic_ab_back_holo_dark);
    	
    	builder.setPositiveButton("YES", new DialogInterface.OnClickListener(){
    		public void onClick(DialogInterface dialog, int whichButton){
    			String msg = "yes" + Integer.toString(whichButton);
    		TextView txtMsg = null;
			txtMsg.setText(msg);
    		}
    	});
    	
    	builder.setNeutralButton("No", new DialogInterface.OnClickListener(){
    		public void onClick(DialogInterface dialog, int whichButton){
    			String msg = "no" + Integer.toString(whichButton);
    		TextView txtMsg = null;
			txtMsg.setText(msg);
    		}
    	});
    	
    	AlertDialog dialog = builder.create();
    	return dialog;
    }
    
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
